home *** CD-ROM | disk | FTP | other *** search
- Path: newsfeed.pitt.edu!jbilla
- From: jbilla+@pitt.edu (Jayadev Billa)
- Newsgroups: comp.lang.c
- Subject: Weird malloc() seg-faults [Need Help!]
- Date: 20 Jan 1996 19:57:36 GMT
- Organization: University of Pittsburgh
- Message-ID: <4drhfg$m9s@usenet.srv.cis.pitt.edu>
- Reply-To: jabst45+@pitt.edu
- NNTP-Posting-Host: scorpion.labs.cis.pitt.edu
- Keywords: malloc, weird, segmentation faults, bad programming?, help
-
- Hi folks:
-
- I have been having problems with seg-faults with malloc.
-
- HW/SW: Pentium-90, 16MB, gcc-2.5.8 with libc-4.5.26.
-
- Description/Setup: I have libraries that I have built up over the past
- year and have had no problem, till now. Specifically the program
- segfaults within malloc, gdb shows the problem as
-
- (gdb) run as1.out
- Starting program: /home/jbilla/HTK/dap/prog/testapf as1.out
- CF # 1 gnuplot testapf.gnu
-
- Program received signal SIGSEGV, Segmentation fault.
- 0xcebc in malloc (size=128) at malloc.c:193
- malloc.c:193: No such file or directory.
- (gdb) where
- #0 0xcebc in malloc (size=128) at malloc.c:193
- #1 0xd8c6 in calloc (nmemb=32, size=4) at calloc.c:33
- #2 0x235e in CreateVector (size=31) at miscmath.c:28
- #3 0xa08d in toeplz (r=0x1af00, x=0x1bf00, y=0x1bc80) at nrmath.c:546
- #4 0x9f05 in stoeplz (r=0x1be00, x=0x1bf00, y=0x1bc80) at nrmath.c:529
- #5 0x5683 in FindDAPFilter (h=0x203000, a=0x1b000) at miscmath.c:911
- #6 0xb049 in main (argc=2, argv=0xbffff904) at testapf.c:102
-
- CreateVector is a simple call to calloc as:
-
- --
-
- typedef float* Vector;
-
- Vector CreateVector(int size)
- {
- Vector vec;
-
- if ((vec = (Vector) calloc(size+1,sizeof(float)))==NULL)
- WError(10,"Unable to allocate memory for Vector");
- *vec = (float) size;
- return(vec);
- }
-
- void FreeVector(Vector vec)
- {
- free(vec);
- }
-
- --
-
- I can't figure out what the problem is. It is reproducible and the calls
- to the routines are valid as far as I can see, memory doesnt seem to be
- a problem (should return NULL anyways for such a case).
-
- I'd apprieciate any help/tips/suggestions. Thanks,
-
- Jay.
- jabst45+@pitt.edu
-
-